@extends('layouts.wechat.application')
@section('content')

    <div class="page-address-list" data-log="地址列表">
        @foreach($addresses as $address)
            <div class="address-manage">
                <div class="ui-card">
                    <ul class="ui-card-item ui-list">
                        <li data-id="{{$address->id}}" class="ui-list-item identity">
                            <a class="delete" href="">删除</a>
                            <span class="consignee">{{$address->name}}</span>
                            <span>{{$address->tel}}</span>
                        </li>
                        <li class="ui-list-item edit" onclick="location.href='{{route('address.edit',$address->id)}}'">
                            <p>{{$address->province}}{{$address->city}}
                                {{$address->area}}
                            </p>
                            <p>{{$address->detail}}</p>
                        </li>
                    </ul>
                </div>
            </div>
        @endforeach


        <div class="add"><a href="new_address.html" class="ui-button ui-button-active"><span>新建地址</span></a></div>
        <div class="popup-risk-check"></div>
    </div>


@endsection
@section('js')
    <script>
        $(function () {
            $('.delete').click(function () {
                var _this = $(this)
                var id = $(this).parents('li').data('id');
                $.ajax({
                    type:'DELETE',
                    url:'/address/'+id,
                    data:{id:id},
                    success:function () {
                        _this.parents('.address-manage').fadeOut(400)
                    }
                })
                return false
            })
        })
    </script>
    @endsection
